<?php
/**
* @package      auto_occasion
* @subpackage   response
* @author       CMS
* @copyright    2011
* @license      All rights reserved
*/

require_once (JELIX_LIB_CORE_PATH.'response/jResponseHtml.class.php');

class frontHtmlResponse extends jResponseHtml {
    
    // Menus
    const MENU_ACCUEIL              = 1;
    const MENU_RECHERCHE            = 2;
    const MENU_FICHE                = 3;
    const MENU_ESSAI                = 4;
    const MENU_ENTREPRISE           = 5;
    const MENU_FIABILITE            = 6;
    const MENU_CONCURRENCE          = 7;
    const MENU_GUIDE_ACHAT          = 8;
    const MENU_LOCALITE             = 9;
    const MENU_LOCALITE_MARQUE      = 10;
    const MENU_LOCALITE_DEPARTEMENT = 11;
    const MENU_ANNONCE_GESTION      = 12;
    const MENU_FAQ                  = 13;
    const MENU_CARTE_GRISE          = 14;
    const MENU_ASSURANCE            = 15;
    const MENU_CREDIT               = 16;
    const MENU_SITE_UTILE           = 17;
    const MENU_QUI_NOUS_SOMMES      = 18;
    const MENU_CONTACT              = 19;
    const MENU_PIECE_AUTO           = 20;
    const MENU_DETAIL_PIECE_AUTO    = 21;
    const MENU_SITE_UTILE_LINKS     = 22;
    const MENU_ANNONCE_MENTION_LEGALE = 23;
    const MENU_CONFIRMATION_CONTACT = 24;
    const MENU_ASSURANCE_AUTO       = 25;
    const MENU_ANNONCE_ADD_DETAIL   = 26;
    const MENU_ANNONCE_GESTION_PHOTO    = 27;
    const MENU_RECHERCHE_PAR_MARQUE     = 28;
    const MENU_RECHERCHE_PAR_CATEGORIE  = 29;
    const MENU_VERSION                  = 30;
    const MENU_ANNONCE_CHOIX_FORMULE    = 31;
    const MENU_CARACTERISTIQUE          = 32;
    const MENU_LAST_FICHE               = 33;
    const MENU_LAST_ESSAIS              = 34;
    /**
    * Menu actif
    */
    var $menusActifs, $breadCrumb;

    function __construct() {
        parent::__construct();

        $this->addJSCode("var j_basepath = '" . $GLOBALS['gJConfig']->urlengine['basePath'] . "';");

        // css
        $this->addCSSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/front/css/auto_occasion.css');
        $this->addCSSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/front/css/skin.css');

        //js
		
        $this->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/front/js/jquery.1.7.1.min.js');
		
        $this->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/front/js/jquery.idTabs.min.js');
        $this->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/front/js/scroll.js');
		
        $this->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/front/js/filter.js');
        $this->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/front/js/common.js');
		$this->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/front/js/jquery.jscroll.js');
        //pour le défilement automatique des annonces
		$this->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/front/js/diapo_defilement.js');
        jClasses::inc('commun~parametre');
        $delayForDiapo = parametre::get(PARAM_DELAY_DIAPO);
        $jsCode = "$(function(){
                        if($('#carrousel-actus').length){
                            setTimeout('defilerDiapo(".$delayForDiapo->param_content.",1)',".$delayForDiapo->param_content.");
                        }
                    });";
        $this->addJSCode($jsCode);
    }

    protected function doAfterActions() {
        global $gJCoord;
        jClasses::inc('commun~sessionSrv');
        jClasses::inc('commun~injectionSrv');

        $p = $gJCoord->request->params;
        //injectionSrv::checkInjection($p); 

        sessionSrv::clean($gJCoord->request->params, 'SESS_ANNONCE_SEARCH');
        sessionSrv::clean($gJCoord->request->params, 'SESS_ANNONCE_MOTCLE');

        if (!isset($this->menusActifs)) {
            throw new Exception("Les menus actifs de la réponse HTML htmlFo doivent etre definit");
        }
        
        $this->body->assignZone('oZoneHeader', 'commun~FoHeader', array ('menusActifs' => $this->menusActifs));
        $this->body->assignZone('oZoneFooter', 'commun~FoFooter', array ('menusActifs' => $this->menusActifs));
        $this->body->assignZone('oZoneScroll', 'commun~FoScroll');
        if (!in_array($this->menusActifs, array(self::MENU_ANNONCE_ADD_DETAIL,self::MENU_ANNONCE_GESTION_PHOTO, self::MENU_ANNONCE_CHOIX_FORMULE))) 
            $this->body->assignZone('oZoneDiapoAnnonce', 'accueil~FoHomeAnnonce');
        $this->body->assignZone('oZoneBreadCrumb', 'commun~FoBreadCrumb', array ('breadCrumb' => $this->breadCrumb));
    }

}
